/****************************************************************************
*                                                                           *
* drawdialog.cpp									                            *
*                                                                           *
* ALaRI 2008												                *
*                                                                           *
****************************************************************************/ 

/****************************************************************************
* Includes                                                                  *
****************************************************************************/ 
#include "drawdialog.h"

#include <QDialogButtonBox>
#include <QLayout>
#include <QGroupBox>
#include <QLabel>
#include <QSpinBox>
#include <QComboBox>


CDrawDialog::CDrawDialog(QWidget *pParent)
	: QDialog(pParent), 
	m_nFromX(0),
	m_nFromY(0),
	m_nToX(0),
	m_nToY(0),
	m_nType(-1)
{
	
	m_pQDialogButtonBox = new QDialogButtonBox(QDialogButtonBox::Ok
								  | QDialogButtonBox::Cancel);

	connect(m_pQDialogButtonBox, SIGNAL(accepted()), SLOT(accept()));
	connect(m_pQDialogButtonBox, SIGNAL(rejected()), SLOT(reject()));

	QGroupBox *pQGroupBoxFrom = new QGroupBox(tr("From: "));
	QLabel *pQLabelFromX = new QLabel(tr("X"));
	QLabel *pQLabelFromY = new QLabel(tr("Y"));
	QSpinBox *pQSpinBoxFromX = new QSpinBox();
	QSpinBox *pQSpinBoxFromY = new QSpinBox();
	pQSpinBoxFromX->setMaximum(4999);
	pQSpinBoxFromY->setMaximum(4999);
	connect(pQSpinBoxFromX, SIGNAL(valueChanged(int)), SLOT(setFromX(int)));  
	connect(pQSpinBoxFromY, SIGNAL(valueChanged(int)), SLOT(setFromY(int)));  
	QGridLayout *pQGridLayoutFrom = new QGridLayout();
	pQGridLayoutFrom->addWidget(pQLabelFromX, 0, 0);
	pQGridLayoutFrom->addWidget(pQSpinBoxFromX, 0, 2);
	pQGridLayoutFrom->addWidget(pQLabelFromY, 1, 0);
	pQGridLayoutFrom->addWidget(pQSpinBoxFromY, 1, 2);
	pQGroupBoxFrom->setLayout(pQGridLayoutFrom);

	QGroupBox *pQGroupBoxTo = new QGroupBox(tr("To:"));
	QLabel *pQLabelToX = new QLabel(tr("X"));
	QLabel *pQLabelToY = new QLabel(tr("Y"));
	QSpinBox *pQSpinBoxToX = new QSpinBox();
	QSpinBox *pQSpinBoxToY = new QSpinBox();
	pQSpinBoxToX->setMaximum(4999);
	pQSpinBoxToY->setMaximum(4999);

	connect(pQSpinBoxToX, SIGNAL(valueChanged(int)), SLOT(setToX(int)));  
	connect(pQSpinBoxToY, SIGNAL(valueChanged(int)), SLOT(setToY(int)));  
	QGridLayout *pQGridLayoutTo = new QGridLayout();
	pQGridLayoutTo->addWidget(pQLabelToX, 0, 0);
	pQGridLayoutTo->addWidget(pQSpinBoxToX, 0, 2);
	pQGridLayoutTo->addWidget(pQLabelToY, 1, 0);
	pQGridLayoutTo->addWidget(pQSpinBoxToY, 1, 2);
	pQGroupBoxTo->setLayout(pQGridLayoutTo);

	QGroupBox *pQGroupBoxType = new QGroupBox(tr("Shape: "));
	QComboBox *pQComboBoxType = new QComboBox(); 
	pQComboBoxType->addItem("Line"); 
	pQComboBoxType->addItem("Rectangle"); 
	pQComboBoxType->addItem("Ellipse"); 
	pQComboBoxType->addItem("Point"); 
	connect(pQComboBoxType, SIGNAL(currentIndexChanged(int)), SLOT(setType(int)));
	m_nType = pQComboBoxType->currentIndex();
	QLabel *pQLabelType = new QLabel(tr("Type"));
	QGridLayout *pQGridLayoutType = new QGridLayout();
	pQGridLayoutType->addWidget(pQLabelType, 0, 0);
	pQGridLayoutType->addWidget(pQComboBoxType, 0, 1);
	pQGroupBoxType->setLayout(pQGridLayoutType);

	QVBoxLayout *pQVBoxLayoutMain = new QVBoxLayout();
	pQVBoxLayoutMain->addWidget(pQGroupBoxFrom);
	pQVBoxLayoutMain->addWidget(pQGroupBoxTo);
	pQVBoxLayoutMain->addWidget(pQGroupBoxType);

	pQVBoxLayoutMain->addWidget(m_pQDialogButtonBox);
	setLayout(pQVBoxLayoutMain);

	setWindowTitle(tr("Draw Special..."));
}

/****************************************************************************
/* End of file																*
****************************************************************************/
